**********************************************
************Appendix regressions**************
**********************************************

***********************
***EFFECTS ON BRIBES***
***********************

use "$data/midline_clean_merged.dta", clear

eststo clear
eststo: reg any_bribe program i.stratum, cluster(a7)
sum any_bribe if program==0
local depvar_mean = `r(mean)'
estadd scalar ControlMean = `depvar_mean'
estadd scalar Observations = `e(N)'
estadd scalar Clusters = `e(N_clust)'

use "$data/endline_clean_merged.dta" , clear

global covariates = "age age2 sex bus1 wealth avg_light_quality"
global dependent_variables= "bribe_self_reclassify bribe_amt bribe_freq bribe_amt1"
foreach depvar in $dependent_variables  {
eststo: reg `depvar' program $covariates i.stratum , cluster(a7)
sum `depvar' if program==0
local depvar_mean = `r(mean)'
estadd scalar ControlMean = `depvar_mean'
estadd scalar Observations = `e(N)'
estadd scalar Clusters = `e(N_clust)'
}
esttab using "$root/outputs/bribes.txt", scalars(Observations Clusters ControlMean) sfmt(0 0 3)  nocons noobs l b(3) se(3) compress nogap r2 nonotes star(* 0.10 ** 0.05 *** 0.01) indicate("Covariates = age age2 sex bus1 wealth avg_light_quality""Stratum FE = *stratum*") nonumbers replace

** Graph of perceptions of others bribing **

twoway hist bribe_freq if program==1, ///
percent xlabel(,valuelabel) ///
barwidth(1) bfcolor(blue%50) blwidth(none) discrete || ///
hist bribe_freq if program==0 , ///
percent xlabel(,valuelabel) ///
barwidth(1) bfcolor(none) blcolor(orange) lwidth(medium)  discrete ///
legend(label(1 "Treatment") label(2 "Control") ring(0) position(1)) xtitle("")
graph export "$root/outputs/others_bribe_graph.pdf", replace

*********************************************
*** ALTERNATIVE MEASURE OF TAX COMPLIANCE ***
*********************************************

use "$data/endline_clean_merged.dta" , clear

global covariates = "age age2 sex bus1 wealth avg_light_quality"

eststo clear
foreach depvar in paid_receipt_union paid_name_or_receipt_only{
eststo: reg `depvar' program i.stratum, cluster(a7)
sum `depvar' if program==0
local depvar_mean = `r(mean)'
estadd scalar ControlMean = `depvar_mean'
estadd scalar Observations = `e(N)'
estadd scalar Clusters = `e(N_clust)'
eststo: reg `depvar' program $covariates i.stratum, cluster(a7)
sum `depvar' if program==0
local depvar_mean = `r(mean)'
estadd scalar ControlMean = `depvar_mean'
estadd scalar Observations = `e(N)'
estadd scalar Clusters = `e(N_clust)'
}
esttab using "$root/outputs/paid_alternative_measure_endline.txt", scalars(Observations Clusters ControlMean) sfmt(0 0 3 3) nocons l b(3) se(3) r2 compress nogap noobs nonotes nonumbers star(* 0.10 ** 0.05 *** 0.01)  ///
indicate("Covariates = age age2 sex bus1 wealth avg_light_quality""Stratum FE = *stratum*") replace


****************************************************
****************************************************
****ROBUSTNESS CHECKS FOR PARTICIPATION OUTCOMES****
****************************************************
****************************************************


******************************
** Controlling for distance **
******************************

use "$data/endline_clean_merged.dta" , clear

global covariates = "age age2 sex bus1 wealth avg_light_quality"
global dependent_variables = "townhall evaluation townhall_or_eval townhall_and_eval participation_index"

eststo clear
eststo: reg townhall program dist_centroid_townhall $covariates i.stratum , cluster(a7)
sum townhall if program==0
local depvar_mean = `r(mean)'
estadd scalar ControlMean = `depvar_mean'
estadd scalar Observations = `e(N)'
estadd scalar Clusters = `e(N_clust)'
eststo: reg evaluation program dist_centroid_dropbox $covariates i.stratum , cluster(a7)
sum townhall if program==0
local depvar_mean = `r(mean)'
estadd scalar ControlMean = `depvar_mean'
estadd scalar Observations = `e(N)'
estadd scalar Clusters = `e(N_clust)'
foreach var in townhall_or_eval townhall_and_eval participation_index{
eststo: reg `var' program dist_centroid_avg $covariates i.stratum , cluster(a7)
sum `var' if program==0
local depvar_mean = `r(mean)'
estadd scalar ControlMean = `depvar_mean'
estadd scalar Observations = `e(N)'
estadd scalar Clusters = `e(N_clust)'
}

esttab using "$root/outputs/participation_distance_control.txt", scalars(Observations Clusters ControlMean) sfmt(0 0 3 3) nocons l b(3) se(3) r2 compress nogap noobs nonotes nonumbers star(* 0.10 ** 0.05 *** 0.01) indicate("Covariates = age age2 sex bus1 wealth avg_light_quality" "Stratum FE = *stratum*")  replace

******************************************
** Imbalanced covariates & interactions ** 
******************************************

use "$data/endline_clean_merged.dta" , clear

global basic_covariates = "age age2 female"
global imbalanced_covariates = "bus1 wealth avg_light_quality"
global imbalanced_interactions = "progXbus1 progXwealth progXavg_light_quality"
global dependent_variables ="townhall evaluation townhall_or_eval townhall_and_eval participation_index cost_participation_rel_w cost_participation2_rel_w"

foreach covariate in $imbalanced_covariates{
cap g progX`covariate' = program*`covariate'
}
eststo clear
foreach depvar in $dependent_variables {
eststo: reg `depvar' program $imbalanced_interactions $imbalanced_covariates $basic_covariates i.stratum, cluster(a7)
sum `depvar' if program==0
local depvar_mean = `r(mean)'
estadd scalar ControlMean = `depvar_mean'
estadd scalar Observations = `e(N)'
estadd scalar Clusters = `e(N_clust)'
}
esttab using "$root/outputs/participation_table_imbalanced_covariates.txt", scalars(Observations Clusters ControlMean) sfmt(%8.1g) r2 nocons noobs l b(3) se(3) compress nogap nonotes nonumbers star(* 0.10 ** 0.05 *** 0.01)  ///
indicate("Basic Covariates = age age2 female" "Stratum FE = *stratum*") nonumbers replace


*******************************************************
*** National Participation and Interest in Politics ***
*******************************************************


use "$data/endline_clean_merged.dta" , clear

global covariates = "age age2 sex bus1 wealth avg_light_quality"
global dependent_variables ="citizen_role_politics interest_politics national_participation "

eststo clear
foreach depvar in $dependent_variables {
eststo: reg `depvar' program $covariates  i.stratum, cluster(a7)
sum `depvar' if program==0
local depvar_mean = `r(mean)'
estadd scalar ControlMean = `depvar_mean'
estadd scalar Observations = `e(N)'
estadd scalar Clusters = `e(N_clust)'
}
foreach depvar in engage_chiefs view_chiefs {
eststo: reg `depvar' program $covariates  i.stratum if chef_job==0, cluster(a7)
sum `depvar' if program==0
local depvar_mean = `r(mean)'
estadd scalar ControlMean = `depvar_mean'
estadd scalar Observations = `e(N)'
estadd scalar Clusters = `e(N_clust)'
}
eststo: reg formalization program $covariates  i.stratum, cluster(a7)
sum formalization if program==0
local depvar_mean = `r(mean)'
estadd scalar ControlMean = `depvar_mean'
estadd scalar Observations = `e(N)'
estadd scalar Clusters = `e(N_clust)'
esttab using "$root/outputs/participation_other_levels.txt", scalars(Observations Clusters ControlMean) sfmt(%8.1g) r2 nocons noobs l b(3) se(3) compress nogap nonotes nonumbers star(* 0.10 ** 0.05 *** 0.01)  ///
indicate("Covariates = age age2 sex bus1 wealth avg_light_quality""Stratum FE = *stratum*") nonumbers replace

************************
** Time gap histogram **
************************

use "$data/endline_clean_merged.dta" , clear

hist time_lag , freq xtitle("Time gap between treatment and outcome measurement (months)") xsc(range(0 420)) xlab(0 "0" 30 "1" 60 "2" 90 "3" 120 "4" 150 "5" 180 "6" 210 "7" 240 "8" 270 "9" 300 "10" 330 "11" 360 "12" 390 "13" 420 "14")
graph export "$root/outputs/time_gap_histogram.pdf", replace


****************************************
** Other heterogeneity table from PAP **
****************************************

use "$data/endline_clean_merged.dta" , clear

global covariates = "age age2 sex bus1 wealth avg_light_quality"
global make_binary = "avg_road_quality avg_light_quality trust7 others4 know_taxes_index"

foreach var in $make_binary {
sum `var', d
g `var'_hi = `var'>`r(p50)'
g progX`var'_hi = program*`var'_hi
}

foreach var in others luluwa {
g progX`var' = program*`var'
}

global interactions = "avg_road_quality_hi avg_light_quality_hi luluwa trust7_hi others others4_hi know_taxes_index_hi"

eststo clear
foreach var in $interactions {
eststo: reg townhall_or_eval program progX`var' `var' $covariates  i.stratum , cluster(a7)
test program progX`var'
estadd scalar Ftest = `r(p)'
sum townhall_or_eval if program==0
local depvar_mean = `r(mean)'
estadd scalar ControlMean = `depvar_mean'
estadd scalar Observations = `e(N)'
estadd scalar Clusters = `e(N_clust)'
}
esttab using "$root/outputs/pap_hte.txt", scalars(Observations Clusters ControlMean Ftest) sfmt(0 0 3 3) r2 nocons noobs l b(3) se(3) compress nogap nonotes star(* 0.10 ** 0.05 *** 0.01)  ///
indicate("Covariates = age age2 sex bus1 wealth avg_light_quality""Stratum FE = *stratum*")  nonumbers replace









********************************
********************************
****Beliefs about government****
********************************
********************************

************************************************
** Responsibility for public goods robustness **
************************************************

use "$data/endline_clean_merged.dta" , clear


global covariates = "age age2 sex bus1 wealth avg_light_quality"
global dependent_variables ="gov_provide gov_provide_sectors gov_provide_aid level_provide"

eststo clear
foreach depvar in $dependent_variables {
eststo: reg `depvar' program $covariates  i.stratum, cluster(a7)
sum `depvar' if program==0
local depvar_mean = `r(mean)'
estadd scalar ControlMean = `depvar_mean'
estadd scalar Observations = `e(N)'
estadd scalar Clusters = `e(N_clust)'
}
esttab using "$root/outputs/public_goods_responsibility.txt", scalars(Observations Clusters ControlMean) sfmt(%8.1g) r2 nocons noobs l b(3) se(3) compress nogap nonotes nonumbers star(* 0.10 ** 0.05 *** 0.01)  ///
indicate("Covariates = age age2 sex bus1 wealth avg_light_quality""Stratum FE = *stratum*") nonumbers replace


***************************************************
** Graph of spending preferences vs expectations **
***************************************************

use "$data/endline_clean_merged.dta" , clear

sum funds_spent // view of current levels of waste
local current_waste = `r(mean)'/1000

keep spend1 spend2 provide*_gov_orig level*_orig

*Expected spending
ta spend1, gen(spend_cat)
forv x=1/9{ 
local y = `x'-1
rename spend_cat`x' spend_cat`y'
}

forv x=0/8{ 
replace spend_cat`x' = 1 if spend2==`x'
}

rename  spend_cat0 waste_exp
rename  spend_cat1 education_exp
rename  spend_cat2 water_exp
rename  spend_cat3 health_exp
rename  spend_cat4 security_exp
rename  spend_cat5 welfare_exp
rename  spend_cat6 development_exp
rename  spend_cat7 infrastructure_exp 
rename  spend_cat8 administration_exp 

drop spend1 spend2

*Perception of responsibility of government
rename provide1_gov education_resp
rename provide2_gov water_resp
rename provide3_gov health_resp
rename provide4_gov security_resp
rename provide5_gov welfare_resp
rename provide6_gov development_resp
rename provide7_gov infrastructure_resp
g waste_resp = 0
g administration_resp = 0

*Perception of current spending
rename level1 education_now
rename level2 water_now
rename level3 health_now
rename level4 security_now
rename level5 welfare_now
rename level6 development_now
rename level7 infrastructure_now
g waste_now = 0
g administration_now = 0

collapse (mean) _all

order _all, alpha

stack _all, into(expectation current_level responsibility) 

label define sectors 1 `"Administration"', modify
label define sectors 2 `"Development"', modify
label define sectors 3 `"Education"', modify
label define sectors 4 `"Health"', modify
label define sectors 5 `"Infrastructure"', modify
label define sectors 6 `"Security"', modify
label define sectors 7 `"Waste/Leakage"', modify
label define sectors 8 `"Water"', modify
label define sectors 9 `"Welfare"', modify
label value _stack sectors
rename _stack sector

*Reorder according to preferences over public goods

sort responsibility
count
g sector_ordered = `r(N)'-_n+1
sort sector_ordered

label define sectors2 9 `"Administration"', modify
label define sectors2 6 `"Development"', modify
label define sectors2 7 `"Education"', modify
label define sectors2 4 `"Health"', modify
label define sectors2 3 `"Infrastructure"', modify
label define sectors2 2 `"Security"', modify
label define sectors2 8 `"Waste/Leakage"', modify
label define sectors2 1 `"Water"', modify
label define sectors2 5 `"Welfare"', modify
label value sector_ordered sectors2

clonevar sector_ordered2 = sector_ordered
clonevar sector_ordered3 = sector_ordered 
replace sector_ordered2 = sector_ordered-0.3
replace sector_ordered3 = sector_ordered+0.3


twoway bar responsibility sector_ordered2 , yaxis(1 2) xlabel(1/9,valuelabel angle(45)) ytitle("Percentage", axis(1)) xtitle("") bfcolor(maroon%50) barw(.3) || bar expectation sector_ordered, bfcolor(blue%50) barw(.3) lc(black) || bar current_level sector_ordered3, bfcolor(green%50) barw(.3) lc(black) ytitle("Spending level (0=low, 1=medium, 2=high)", axis(2)) legend(label(2 "Expected spending from taxes (left axis)") label(1 "Resp. for public goods provision (left axis)") label(3 "Actual public goods provision (right axis)") ring(0) position(1)) 

graph export "$root/outputs/spending_combined.pdf", replace


************************************
** Perceived v. actual compliance **
************************************

use "$data/endline_clean_merged.dta" , clear

bysort a7: egen avg_actual_compliance = mean(paid_receipt_union)
g gap_indiv_perceived_actual_comp = perceived_compliance-avg_actual_compliance

sum gap_indiv_perceived_actual_comp if program==1, d
hist gap_indiv_perceived_actual_comp if program==1, bin(25) ///
xline(`r(mean)', lcolor(red)) ///
xtitle("Gap between perceived and actual property tax compliance")
graph export "$root/outputs/perceived_actual_compliance.pdf", replace











********************************
********************************
*** ALTERNATIVE EXPLANATIONS ***
********************************
********************************



*********************************************
*** Trust and familiarity with researchers **
*********************************************

use "$data/endline_clean_merged.dta" , clear


global covariates = "age age2 sex bus1 wealth avg_light_quality"

eststo clear
foreach depvar in trust7 knows_employer old_respondent no_phone bad_phone {
eststo: reg `depvar' program $covariates i.stratum  , cluster(a7)
sum `depvar' if program==0
local depvar_mean = `r(mean)'
estadd scalar ControlMean = `depvar_mean'
estadd scalar Observations = `e(N)'
estadd scalar Clusters = `e(N_clust)'
}
esttab using "$root/outputs/researcher_influence.txt", scalars(Observations Clusters ControlMean) sfmt(0 0 3 3) nocons noobs l b(3) se(3) compress nogap  r2 nonotes star(* 0.10 ** 0.05 *** 0.01) nonumbers replace indicate("Covariates = age age2 sex bus1 wealth avg_light_quality""Stratum FE = *stratum*")



*******************************
****Examine flier receivers****
*******************************

use "$data/endline_clean_merged.dta" , clear

global covariates = "age age2 sex bus1 wealth avg_light_quality"
global dependent_variables = "know_taxes_index townhall_or_eval"

eststo clear
foreach depvar in $dependent_variables {
eststo: reg `depvar' flier $covariates i.stratum if program==0, cluster(a7)
sum `depvar' if program==0
local depvar_mean = `r(mean)'
estadd scalar ControlMean = `depvar_mean'
estadd scalar Observations = `e(N)'
estadd scalar Clusters = `e(N_clust)'
}
eststo: reg townhall_or_eval program $covariates i.stratum if control_flier_receiver==0, cluster(a7)
sum townhall_or_eval if program==0 & flier==0
local depvar_mean = `r(mean)'
estadd scalar ControlMean = `depvar_mean'
estadd scalar Observations = `e(N)'
estadd scalar Clusters = `e(N_clust)'
esttab using "$root/outputs/flier_effects.txt", scalars(Observations Clusters ControlMean) sfmt(%8.1g) ///
 r2 nocons noobs l b(3) se(3) compress nogap nonotes nonumbers star(* 0.10 ** 0.05 *** 0.01)  ///
indicate("Covariates = age age2 sex bus1 wealth avg_light_quality""Stratum FE = *stratum*") nonumbers replace




********************************************************
*** Distance to treatment (in control) & vice versa ****
********************************************************

use "$data/endline_clean_merged.dta" , clear


*Examine whether people who live near border of treated polygons next to control polygon participate at different rates

twoway lpolyci townhall_or_eval dist_to_control if dist_to_control<0.2, bw(.02) ///
yscale(range(0(.05).4)) ylab(0(.05).4) xscale(range(0(.05).18)) xlab(0(.05).18) ytitle("Participation rate") ///
legend(label(2 "Local polynomial") ring(0) position(1)) ///
xtitle("Distance from control neighborhood (km)")
graph export "$root/outputs/participation_near_control.pdf", replace


*Examine whether people in control who live near treated polygons participate more
twoway lpolyci townhall_or_eval dist_to_treat if program==0 & dist_to_treat<0.2, bw(.02) ///
yscale(range(0(.05).4)) ylab(0(.05).4) xscale(range(0(.05).18)) xlab(0(.05).18) ytitle("Participation rate") ///
legend(label(2 "Local polynomial") ring(0) position(1)) ///
xtitle("Distance from treatment neighborhood (km)")
graph export "$root/outputs/participation_near_treatment.pdf", replace


***************************************************
** Sample 2 (from baseline): changes in control? **
***************************************************

use "$data/endline_clean_merged_sample2.dta", clear

xtset s3_code endline

global depvars = "eval_gov trust_gov gov_integrity gov_provide"

eststo clear
foreach depvar in $depvars {
eststo: xtreg `depvar' endline if program==0, cluster(a7) fe
sum `depvar' if program==0 & endline==0
local depvar_mean = `r(mean)'
estadd scalar ControlMean = `depvar_mean'
estadd scalar Observations = `e(N)'
estadd scalar Clusters = `e(N_clust)'
}
esttab using "$root/outputs/sample2_belief_changes.txt", scalars(Observations Clusters ControlMean) sfmt(0 0 3 ) nocons r2 noobs l b(3) se(3) compress nogap nonotes nonumbers star(* 0.10 ** 0.05 *** 0.01)  nonumbers replace





*******************
*******************
*** MECHANISMS ****
*******************
*******************

***************************
** Entitlement mechanism ** 
***************************


************************************
***Coefficient Stability Analysis***
************************************

use "$data/endline_clean_merged.dta" , clear

global covariates1 = "age age2 sex"
global covariates2 = "log_inc wealth avg_light_quality"
global covariates3 = "edu_yrs unemployed bus1 work_gov born_kga luluwa "


eststo clear
eststo: reg townhall_or_eval paid_receipt_union if program==1, cluster(a7)
sum townhall_or_eval if program==1
local depvar_mean = `r(mean)'
estadd scalar DepVarMean = `depvar_mean'
estadd scalar Observations = `e(N)'
estadd scalar Clusters = `e(N_clust)'
eststo: reg townhall_or_eval paid_receipt_union $covariates1 i.stratum if  program==1, cluster(a7)
sum townhall_or_eval if  program==1
local depvar_mean = `r(mean)'
estadd scalar DepVarMean = `depvar_mean'
estadd scalar Observations = `e(N)'
estadd scalar Clusters = `e(N_clust)'
eststo: reg townhall_or_eval paid_receipt_union $covariates1 $covariates2 $covariates3 i.stratum if  program==1, cluster(a7)
sum townhall_or_eval if program==1
local depvar_mean = `r(mean)'
estadd scalar DepVarMean = `depvar_mean'
estadd scalar Observations = `e(N)'
estadd scalar Clusters = `e(N_clust)'
eststo: reg townhall_or_eval paid_receipt_union $covariates1 $covariates2 $covariates3 funds_spent i.stratum if  program==1, cluster(a7)
sum townhall_or_eval if program==1
local depvar_mean = `r(mean)'
estadd scalar DepVarMean = `depvar_mean'
estadd scalar Observations = `e(N)'
estadd scalar Clusters = `e(N_clust)'
esttab using "$root/outputs/payment_bias_analysis.txt", ///
scalars(Observations Clusters DepVarMean) sfmt(0 0 3 3) ///
nocons r2 noobs l b(3) se(3) compress nogap nonotes ///
star(* 0.10 ** 0.05 *** 0.01) nonumbers replace ///
indicate("Stratum FE = *stratum*")

*Oster coefficient stability analysis

forv x=.05(.01).15{
psacalc delta paid_receipt_union, beta(`x')
local scaler = round(`x'*100, 1)
g magnitude`scaler' = `r(delta)'
}

keep magnitude*
collapse (mean) _all
stack _all, into(magnitude)

local counter = 1
forv x=.05(.01).15{
replace _stack = `x' if _stack==`counter'
local counter = `counter'+1
}
rename magnitude needed_selection
rename _stack effect_size

twoway scatter needed_selection effect_size, xtitle("Effect of payment on participation") ytitle("Needed selection on unobservables") yscale(range(0.1 -.6)) ylab(0.1(.1)-.6) yline(0, lcolor(red))
graph export "$root/outputs/needed_selection_payment.pdf", replace

****************************************
** Collector effort and effectiveness **
****************************************

use "$data/endline_clean_merged.dta" , clear
global covariates = "age age2 sex bus1 wealth avg_light_quality"


global collectors = "Aime	Andre	AnneMarie	Antoinette	Antho	Dominique	Jean	John	Joseph	Timothe	Isidore	Touby	Ilunga	Francois	Paulin	Charles	Donatien	Tony	Nana	Constantin	Augustin	Daniel	Boniface	Crispin	Richard	Florent	Henriette	Josue	Mado	Alain	Hyppolite	Solange	Alphonse	Christophe	Theo	Kapinga	Jerome JeanJacques	Raphael	Patrick	Camile	Junior	Jonathan	Tshibalu " 

foreach collector of global collectors {
gen `collector' =  col1_union == "`collector'"|col2_union == "`collector'"|col3_union == "`collector'"|col4_union == "`collector'"|col5_union == "`collector'"
}

global colnames=""
foreach collector of varlist $collectors {
local counter = `counter' + 1

sum visits if `collector'==1
local visited_pct = round(`r(mean)',.001)
sum paid_receipt_union if `collector'==1
local paid_pct = round(`r(mean)',.001)

reg paid_receipt_union visits $covariates i.stratum if `collector'==1, cluster(a7)
local corr = round(_b[visits],.001)
local se = round(_se[visits],.001)
local p = round(2*ttail(e(df_r), abs(_b[visits]/_se[visits])),.001)

	if `counter' == 1 { 
		mat input collector = (`visited_pct', `paid_pct',`corr',`se' ,`p') 
	}
	

	if `counter' != 1 { 
		mat input collector`counter' = (`visited_pct', `paid_pct',`corr',`se',`p') 
		mat collector = (collector \ collector`counter' )
	}
	global colnames = "$colnames Collector`counter'"

}
	
	
	mata collector = st_matrix("collector") 
	mat list collector 	
	mata : st_matrix("collector", sort(st_matrix("collector"), 1))
	mat list collector 	


	clear
	getmata (var*) = collector
	list
	rename var1 visits
	rename var2 paid
	rename var3 correlation
	rename var4 SE
	rename var5 pvalue
	g lb=correlation-2*SE
	g ub = correlation+2*SE
		
	drop if correlation<=0
	sort lb
		g collector =_n

	twoway (rcap lb ub collector) (scatter correlation collector, xline(35.5,lcolor(red)) ytitle("Correlation coefficient") xtitle("Collector") legend(off))
	graph export "$root/outputs/visits_payment_collectors.pdf", replace




************************
**IV FIRST STAGE TABLE**
************************

use "$data/endline_clean_merged.dta" , clear
global covariates = "age age2 sex bus1 wealth avg_light_quality"

eststo clear
eststo: reg registered registered_jive_u_avg  double_bonus $covariates i.stratum if program==1, cluster(a7)
estadd scalar Observations = `e(N)'
estadd scalar Clusters = `e(N_clust)'
test registered_jive_u_avg double_bonus
estadd scalar Fstat=`r(F)'
sum registered if program==1
local depvar_mean = `r(mean)'
estadd scalar DepVarMean = `depvar_mean'
eststo: reg registered registered_jive_u_avg double_bonus $covariates i.stratum i.a1 if program==1, cluster(a7)
estadd scalar Observations = `e(N)'
estadd scalar Clusters = `e(N_clust)'
test registered_jive_u_avg double_bonus
estadd scalar Fstat=`r(F)'
sum registered if program==1
local depvar_mean = `r(mean)'
estadd scalar DepVarMean = `depvar_mean'
eststo: reg paid_receipt_union paid_jive_u_avg double_bonus $covariates i.stratum if program==1  , cluster(a7)
estadd scalar Observations = `e(N)'
estadd scalar Clusters = `e(N_clust)'
test paid_jive_u_avg double_bonus
estadd scalar Fstat=`r(F)'
sum paid_receipt_union if program==1
local depvar_mean = `r(mean)'
estadd scalar DepVarMean = `depvar_mean'
eststo: reg paid_receipt_union paid_jive_u_avg double_bonus $covariates i.stratum i.a1 if program==1 , cluster(a7)
estadd scalar Observations = `e(N)'
estadd scalar Clusters = `e(N_clust)'
test paid_jive_u_avg double_bonus
estadd scalar Fstat=`r(F)'
sum paid_receipt_union if program==1
local depvar_mean = `r(mean)'
estadd scalar DepVarMean = `depvar_mean'
eststo: reg paid_receipt_union paid_jive_u_avg double_bonus $covariates i.stratum if program==1 & registered==1, cluster(a7)
estadd scalar Observations = `e(N)'
estadd scalar Clusters = `e(N_clust)'
test paid_jive_u_avg double_bonus
estadd scalar Fstat=`r(F)'
sum paid_receipt_union if program==1 & registered==1
local depvar_mean = `r(mean)'
estadd scalar DepVarMean = `depvar_mean'
eststo: reg paid_receipt_union paid_jive_u_avg double_bonus $covariates i.stratum i.a1 if program==1 & registered==1 , cluster(a7)
estadd scalar Observations = `e(N)'
estadd scalar Clusters = `e(N_clust)'
test paid_jive_u_avg double_bonus
estadd scalar Fstat=`r(F)'
sum paid_receipt_union if program==1 & registered==1
local depvar_mean = `r(mean)'
estadd scalar DepVarMean = `depvar_mean'

esttab using "$root/outputs/complier_margins_first_stage.txt", scalars(DepVarMean Clusters Observations Fstat) sfmt(3 0 0 3) nocons l b(3) se(3) compress nogap nonotes star(* 0.10 ** 0.05 *** 0.01) noobs ///
indicate("Covariates = age age2 sex bus1 wealth avg_light_quality""Stratum FE = *stratum*""Enum FE=*a1*") nonumbers replace

**************************************
***IV IDENTIFYING ASSUMPTION CHECK****
**************************************

**Correlate instruments with midline survey non-response

use "$data/endline_clean_merged.dta" , clear

preserve
use "$data/midline_clean_merged.dta", clear
collapse (mean) respondent, by(a7)
rename respondent survey2_neighborhood_response
tempfile survey2_nonresponse
sa `survey2_nonresponse'
restore

merge m:1 a7 using `survey2_nonresponse', keep(1 3)

global instruments = "paid_jive_u_avg registered_jive_u_avg"
g survey2_neighborhood_nonresponse = 1-survey2_neighborhood_response

eststo clear
foreach var in $instruments{
eststo: reg survey2_neighborhood_nonresponse `var' $covariates i.stratum if program==1, cluster(a7)
sum survey2_neighborhood_nonresponse if  program==1
local depvar_mean = `r(mean)'
estadd scalar DepVarMean = `depvar_mean'
estadd scalar Observations = `e(N)'
estadd scalar Clusters = `e(N_clust)'
eststo: reg survey2_neighborhood_nonresponse `var' $covariates i.stratum i.a1 if program==1, cluster(a7)
sum survey2_neighborhood_nonresponse if  program==1
local depvar_mean = `r(mean)'
estadd scalar DepVarMean = `depvar_mean'
estadd scalar Observations = `e(N)'
estadd scalar Clusters = `e(N_clust)'
}
esttab using "$root/outputs/instruments_s2_nonresponse.txt", ///
scalars(Observations Clusters DepVarMean) sfmt(0 0 3 3) ///
nocons r2 noobs l b(3) se(3) compress nogap nonotes ///
star(* 0.10 ** 0.05 *** 0.01) nonumbers replace ///
indicate("Covariates = age age2 sex bus1 wealth avg_light_quality" ///
"Stratum FE = *stratum*""Enumerator FE = *a1*")

***********************************
** Updating beliefs by subgroups **
***********************************

use "$data/endline_clean_merged.dta" , clear

global covariates = "age age2 sex bus1 wealth avg_light_quality"
global dependent_variables = "gov_provide capacity_info capacity_punish others4 eval_trust_tax capacity_provide eval_trust_gov funds_deposited  funds_spent transparency "

local counter = 0

eststo clear
foreach depvar in $dependent_variables  {
local counter = `counter' + 1

areg `depvar' program $covariates , cluster(a7) absorb(stratum)
local beta1 = round(_b[program],.001)
di "Beta: `beta1'"
local se1 = round(_se[program],.001)
di "SE: `se1'"
local p1 = round(2*ttail(e(df_r), abs(_b[program]/_se[program])),.001)
di "p-value: `p1'"

areg `depvar' program $covariates if registered==1 | program==0, cluster(a7) absorb(stratum)
local beta2 = round(_b[program],.001)
di "Beta: `beta2'"
local se2 = round(_se[program],.001)
di "SE: `se2'"
local p2 = round(2*ttail(e(df_r), abs(_b[program]/_se[program])),.001)
di "p-value: `p2'"

areg `depvar' program $covariates if  paid_receipt_union==0, cluster(a7)  absorb(stratum)
local beta3 = round(_b[program],.001)
di "Beta: `beta3'"
local se3 = round(_se[program],.001)
di "SE: `se3'"
local p3 = round(2*ttail(e(df_r), abs(_b[program]/_se[program])),.001)
di "p-value: `p3'"

areg `depvar' program $covariates if register_not_pay==1 | program==0, cluster(a7) absorb(stratum)
local beta4 = round(_b[program],.001)
di "Beta: `beta4'"
local se4 = round(_se[program],.001)
di "SE: `se4'"
local p4 = round(2*ttail(e(df_r), abs(_b[program]/_se[program])),.001)
di "p-value: `p4'"

	if `counter' == 1 { 
		mat input reg1a = (`beta1', `beta2', `beta3',`beta4')
		mat input reg1b = (`se1', `se2', `se3',`se4') 
		mat reg = reg1a \ reg1b
	}
	

	if `counter' != 1 { 
		mat input reg`counter'a = (`beta1', `beta2', `beta3',`beta4') 
		mat input reg`counter'b = (`se1', `se2', `se3',`se4') 
		mat reg`counter' = reg`counter'a \ reg`counter'b
		mat reg = (reg \ reg`counter' )
	}

}
		
	mata reg = st_matrix("reg") 
	mat list reg 	
		
	mmat2tex reg using "$root/outputs/beliefs_by_subgroups.txt", replace colnames(treatmenteffect registered nopayers regnotpay) 	rownames("Resp. for public goods provision" " " "Information about citizens" " " "Ability to punish evaders" " " "Perceived citizen compliance"  " " "Performance of tax ministry"  " " 	"Ability to provide public goods"  " " "Performance of government"  " " "Integrity of tax collectors"  " " "Integrity of government spending" " " "Transparency of government" " " ) preheader("{\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} \begin{tabular}{l*{5}{c}} \hline\hline") bottom("\hline\hline \end{tabular} }") fmt(%9.3f)

	
***************************************
** Beliefs in subgroups of treatment **
***************************************

use "$data/endline_clean_merged.dta" , clear

global covariates = "age age2 sex bus1 wealth avg_light_quality"
global dependent_variables = "gov_provide capacity_info capacity_punish others4 eval_trust_tax capacity_provide eval_trust_gov funds_deposited  funds_spent transparency "


local counter=0

eststo clear
foreach depvar in $dependent_variables  {
local counter = `counter' + 1

areg `depvar' program $covariates , cluster(a7) absorb(stratum)
local beta1 = round(_b[program],.001)
di "Beta: `beta1'"
local se1 = round(_se[program],.001)
di "SE: `se1'"
local p1 = round(2*ttail(e(df_r), abs(_b[program]/_se[program])),.001)
di "p-value: `p1'"

areg `depvar' registered $covariates if program==1, cluster(a7)  absorb(stratum)
local beta2 = round(_b[registered],.001)
di "Beta: `beta2'"
local se2 = round(_se[registered],.001)
di "SE: `se2'"
local p2 = round(2*ttail(e(df_r), abs(_b[registered]/_se[registered])),.001)
di "p-value: `p2'"

areg `depvar' paid_receipt_union $covariates if program==1, cluster(a7)  absorb(stratum)
local beta3 = round(_b[paid_receipt_union],.001)
di "Beta: `beta3'"
local se3 = round(_se[paid_receipt_union],.001)
di "SE: `se3'"
local p3 = round(2*ttail(e(df_r), abs(_b[paid_receipt_union]/_se[paid_receipt_union])),.001)
di "p-value: `p3'"

areg `depvar' townhall_and_eval $covariates if program==1, cluster(a7) absorb(stratum)
local beta4 = round(_b[townhall_and_eval],.001)
di "Beta: `beta4'"
local se4 = round(_se[townhall_and_eval],.001)
di "SE: `se4'"
local p4 = round(2*ttail(e(df_r), abs(_b[townhall_and_eval]/_se[townhall_and_eval])),.001)
di "p-value: `p4'"

	if `counter' == 1 { 
		mat input reg1a = (`beta1', `beta2', `beta3',`beta4')
		mat input reg1b = (`se1', `se2', `se3',`se4') 
		mat reg = reg1a \ reg1b
	}
	

	if `counter' != 1 { 
		mat input reg`counter'a = (`beta1', `beta2', `beta3',`beta4') 
		mat input reg`counter'b = (`se1', `se2', `se3',`se4') 
		mat reg`counter' = reg`counter'a \ reg`counter'b
		mat reg = (reg \ reg`counter' )
	}

}
	
	
	mata reg = st_matrix("reg") 
	mat list reg 	
		
	mmat2tex reg using "$root/outputs/beliefs_by_subgroups_intreatment.txt", replace  ///
	colnames(treatmenteffect registered payers participators) ///
	rownames("Resp. for public goods provision" " " "Information about citizens" " " "Ability to punish evaders" " " ///
	"Perceived citizen compliance"  " " "Performance of tax ministry"  " " ///
	"Ability to provide public goods"  " " "Performance of government"  " " "Integrity of tax collectors"  " " "Integrity of government spending" " " "Transparency of government" " ") ///
	preheader("{\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} \begin{tabular}{l*{5}{c}} \hline\hline") ///
	bottom("\hline\hline \end{tabular} }") ///
	fmt(%9.3f)


	
	
*************************************************
***Heterogeneous effects by baseline variables***
*************************************************

use "$data/endline_clean_merged.dta" , clear

global covariates = "age age2 sex bus1 wealth avg_light_quality"

eststo clear
foreach depvar in townhall_or_eval{
eststo: reg `depvar' program $covariates  i.stratum , cluster(a7)
sum `depvar' if program==0
local depvar_mean = `r(mean)'
estadd scalar ControlMean = `depvar_mean'
estadd scalar Observations = `e(N)'
estadd scalar Clusters = `e(N_clust)'
eststo: reg `depvar' program progXvisited_past visited_past_hi  $covariates  i.stratum , cluster(a7)
sum `depvar' if program==0
local depvar_mean = `r(mean)'
estadd scalar ControlMean = `depvar_mean'
estadd scalar Observations = `e(N)'
estadd scalar Clusters = `e(N_clust)'
test program progXvisited_past
estadd scalar Ftest = `r(p)'
eststo: reg `depvar' program progXbaseline_protest past_protest_hi $covariates  i.stratum , cluster(a7)
sum `depvar' if program==0
local depvar_mean = `r(mean)'
estadd scalar ControlMean = `depvar_mean'
estadd scalar Observations = `e(N)'
estadd scalar Clusters = `e(N_clust)'
test program progXbaseline_protest
estadd scalar Ftest = `r(p)'
}
esttab using "$root/outputs/heterogeneity_past_exposure.txt", scalars(Observations Clusters ControlMean Ftest) sfmt(%8.1g) r2 nocons noobs l b(3) se(3) compress nogap nonotes nonumbers star(* 0.10 ** 0.05 *** 0.01)indicate("Covariates = age age2 sex bus1 wealth avg_light_quality""Stratum FE = *stratum*")  nonumbers replace



************************
***SPILLOVER ANALYSIS***
************************

use "$data/endline_clean_merged.dta" , clear

global covariates = "age age2 sex bus1 wealth avg_light_quality"
global depvars = "visited paid_receipt_union townhall_or_eval"

eststo clear
foreach depvar in $depvars {
eststo: reg `depvar' program $covariates treated_neighbors total_neighbors  i.stratum , cluster(a7)
sum `depvar' if program==0
local depvar_mean = `r(mean)'
estadd scalar ControlMean = `depvar_mean'
estadd scalar Observations = `e(N)'
estadd scalar Clusters = `e(N_clust)'
eststo: reg `depvar' program $covariates length_treated_neighbors length_all_neighbors i.stratum , cluster(a7)
sum `depvar' if program==0
local depvar_mean = `r(mean)'
estadd scalar ControlMean = `depvar_mean'
estadd scalar Observations = `e(N)'
estadd scalar Clusters = `e(N_clust)'
}
esttab using "$root/outputs/spillovers.txt", scalars(Observations Clusters ControlMean) sfmt(%8.1g) r2 nocons noobs l b(3) se(3) compress nogap nonotes nonumbers star(* 0.10 ** 0.05 *** 0.01) indicate("Covariates = age age2 sex bus1 wealth avg_light_quality""Stratum FE = *stratum*") nonumbers replace



**************************
** BARGAINING MECHANISM **
**************************	
	
******************************
** Evaluations with demands **
******************************

use "$data/endline_clean_merged.dta" , clear

global covariates = "age age2 sex bus1 wealth avg_light_quality"
global depvars= "eval_box_disapprove eval_comment"

eststo clear
foreach depvar in $depvars{
eststo: reg `depvar' program $covariates  i.stratum , cluster(a7)
sum `depvar' if program==0
local depvar_mean = `r(mean)'
estadd scalar ControlMean = `depvar_mean'
estadd scalar Observations = `e(N)'
estadd scalar Clusters = `e(N_clust)'
}
esttab using "$root/outputs/evaluations_with_demands.txt", scalars(Observations Clusters ControlMean Ftest) sfmt(0 0 3 3) r2 nocons noobs l b(3) se(3) compress nogap nonotes star(* 0.10 ** 0.05 *** 0.01)  ///
indicate("Covariates = age age2 sex bus1 wealth avg_light_quality""Stratum FE = *stratum*") ///
addnote("\scriptsize{Standard errors clustered by polygon. $^* p<0.1, ^{**} p<0.05, ^{***} p<0.01$. p-value of interaction F test shown.}") nonumbers replace


**************************
*** Evaluation Topics ****
**************************

use "$data/endline_clean_merged.dta" , clear

label define sa_short 4 `"++"', modify
label define sa_short 3 `"+"', modify
label define sa_short 2 `"_"', modify
label define sa_short 1 `"--"', modify
label define sa_short 0 `"DK"', modify

foreach var in eval6_box eval7_box eval8_box eval8_box{
label value `var' sa_short
}

foreach var of varlist eval6_box eval7_box eval8_box eval9_box{
label value `var' sa_short
hist `var' if `var'!=0, percent xlabel(1/4,valuelabel) ytitle(,size(medlarge)) xtitle(,size(medlarge)) yscale(range(0 60)) ylab(0(20)60) barwidth(.8) bfcolor(midblue) bcolor(black) discrete saving(`var', replace)
}

graph combine eval6_box.gph eval7_box.gph eval8_box.gph eval9_box.gph,caption("++ 'strongly agree', + 'agree', - 'disagree', -- 'strongly disagree'", size(small))

graph export "$root/outputs/evaluation_content.pdf", replace


******************************
*** COORDINATION MECHANISM ***
******************************

use "$data/endline_clean_merged.dta" , clear

global covariates = "age age2 sex bus1 wealth avg_light_quality"

bysort a7: egen participation_by_polygon = mean(townhall)

eststo clear
eststo: reg arrived_neighbor program $covariates i.stratum, cluster(a7)
sum arrived_neighbor if program==0
local depvar_mean = `r(mean)'
estadd scalar ControlMean = `depvar_mean'
estadd scalar Observations = `e(N)'
estadd scalar Clusters = `e(N_clust)'
eststo: reg arrived_neighbor program participation_by_polygon $covariates i.stratum, cluster(a7)
estadd scalar ControlMean = `depvar_mean'
estadd scalar Observations = `e(N)'
estadd scalar Clusters = `e(N_clust)'
eststo: reg arrived_neighbor program participation_by_polygon pop_density $covariates i.stratum, cluster(a7)
estadd scalar ControlMean = `depvar_mean'
estadd scalar Observations = `e(N)'
estadd scalar Clusters = `e(N_clust)'
esttab using "$root/outputs/townhall_arrivals.txt", scalars(Observations Clusters ControlMean) sfmt(%8.1g) r2 nocons noobs l b(3) se(3) compress nogap nonotes nonumbers star(* 0.10 ** 0.05 *** 0.01)  ///
indicate("Covariates = age age2 sex bus1 wealth avg_light_quality""Stratum FE = *stratum*") nonumbers replace

** Table looking at distance to other participators **

bysort a7: egen poly_participation = mean(townhall_or_eval)

eststo clear
eststo: reg avg_dist_participators program i.stratum, r
sum avg_dist_participators if program==0
local depvar_mean = `r(mean)'
estadd scalar ControlMean = `depvar_mean'
estadd scalar Observations = `e(N)'
eststo: reg avg_dist_participators program poly_participation i.stratum, r
sum avg_dist_participators if program==0
local depvar_mean = `r(mean)'
estadd scalar ControlMean = `depvar_mean'
estadd scalar Observations = `e(N)'
eststo: reg avg_dist_participators program poly_participation pop_density i.stratum, r
sum avg_dist_participators if program==0
local depvar_mean = `r(mean)'
estadd scalar ControlMean = `depvar_mean'
estadd scalar Observations = `e(N)'
esttab using "$root/outputs/hh_distances_participators.txt", scalars(Observations ControlMean) sfmt(%8.1g) r2 nocons noobs l b(3) se(3) compress nogap nonotes nonumbers star(* 0.10 ** 0.05 *** 0.01)  ///
indicate("Stratum FE = *stratum*") nonumbers replace








***********************
***********************
***Robustness Tables***
***********************
***********************

use "$data/endline_clean_merged.dta" , clear

global depvars= "paid_receipt_union townhall evaluation townhall_or_eval townhall_and_eval participation_index cost_participation_rel_w cost_participation2_rel_w gov_provide capacity_info capacity_punish others4 eval_trust_tax capacity_provide eval_trust_gov funds_deposited  funds_spent transparency"
global covs1 = "age age2 sex"
global covs2 = "edu_yrs log_inc wealth bus1 work_gov property1"
global covs_baseline = "avg_road_quality avg_light_quality hh_quality past_collector_visit past_payment political_participation gov_trust gov_eval govimpprovide gov_corrupt"
global covs_all = "$covs1 $covs2 $covs_baseline"

local counter = 1
foreach depvar in $depvars{
areg `depvar' program , cluster(a7) absorb(stratum)
local beta0 = round(_b[program],.001)
di "Beta: `beta0'"
local se0 = round(_se[program],.001)
di "SE: `se0'"
local p0 = round(2*ttail(e(df_r), abs(_b[program]/_se[program])),.001)
di "p-value: `p0'"

areg `depvar' program $covs1 , cluster(a7) absorb(stratum)
local beta1 = round(_b[program],.001)
di "Beta: `beta1'"
local se1 = round(_se[program],.001)
di "SE: `se1'"
local p1 = round(2*ttail(e(df_r), abs(_b[program]/_se[program])),.001)
di "p-value: `p1'"

areg `depvar' program $covs_all i.time_xtile10, cluster(a7) absorb(stratum)
local beta2 = round(_b[program],.001)
di "Beta: `beta2'"
local se2 = round(_se[program],.001)
di "SE: `se2'"
local p2 = round(2*ttail(e(df_r), abs(_b[program]/_se[program])),.001)
di "p-value: `p2'"

areg `depvar' program  $covariates i.stratum , cluster(a7) absorb( a1)
local beta3 = round(_b[program],.001)
di "Beta: `beta3'"
local se3 = round(_se[program],.001)
di "SE: `se3'"
local p3 = round(2*ttail(e(df_r), abs(_b[program]/_se[program])),.001)
di "p-value: `p3'"

areg `depvar' program $covariates  [pweight = final_weight_norm] , cluster(a7) absorb(stratum)
local beta4 = round(_b[program],.001)
di "Beta: `beta4'"
local se4 = round(_se[program],.001)
di "SE: `se4'"
local p4 = round(2*ttail(e(df_r), abs(_b[program]/_se[program])),.001)
di "p-value: `p4'"

areg `depvar' program programXhouse house1 $covariates  , cluster(a7) absorb(stratum)
local beta5 = round(_b[program],.001)
di "Beta: `beta5'"
local se5 = round(_se[program],.001)
di "SE: `se5'"
local p5 = round(2*ttail(e(df_r), abs(_b[program]/_se[program])),.001)
di "p-value: `p5'"
local beta6 = round(_b[programXhouse],.001)
di "Beta: `beta6'"
local se6 = round(_se[programXhouse],.001)
di "SE: `se6'"
local p6 = round(2*ttail(e(df_r), abs(_b[programXhouse]/_se[program])),.001)
di "p-value: `p6'"
test program=programXhouse
local ftest = `r(p)'
di "F stat p-value = `ftest'"

	if `counter' == 1 { 
		mat input reg1a = (`beta0', `beta1', `beta2', `beta3',`beta4',`beta5',`beta6',`ftest')
		mat input reg1b = (`se0', `se1', `se2', `se3',`se4',`se5',`se6',`ftest') 
		mat reg = reg1a \ reg1b
	}
	

	if `counter' != 1 { 
		mat input reg`counter'a = (`beta0',`beta1', `beta2', `beta3',`beta4',`beta5',`beta6',`ftest') 
		mat input reg`counter'b = (`se0',`se1', `se2', `se3',`se4',`se5',`se6',`ftest') 
		mat reg`counter' = reg`counter'a \ reg`counter'b
		mat reg = (reg \ reg`counter' )
	}

	local counter = `counter'+1
}
	
	
	mata reg = st_matrix("reg") 
	mat list reg 	

	
	mmat2tex reg using "$root/outputs/robustness.txt", replace  ///
	colnames(beta0 beta1 beta2 beta3 beta4 beta5 beta6 ftest) ///
	rownames("Paid property tax" " " "Townhall meeting attendance" " " "Evaluation submission" " " "Townhall or evaluation" " " ///
	"Townhall and evaluation" " " "Costly participation index" " " "Cost of participation (transport)" " " ///
	"Cost of participation (transport \& opp.)" " " "Resp. prov. govt (full index)" " " ///
	"Information about taxpayers" " " "Ability to punish evaders" " " "Perceived citizen compliance" " " ///
	"Performance of tax ministry"  " " 	"Ability to provide public goods"  " " "Performance of government"  " " ///
	"Integrity of tax collectors"  " " "Integrity of government"  " " "Transparency of government" " ") ///
	preheader("{\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} \begin{tabular}{l*{8}{c}} \hline\hline") ///
	bottom("\hline\hline \end{tabular} }") ///
	fmt(%9.3f)

	

**********************
***AES COEFFICIENTS***
**********************

use "$data/endline_clean_merged.dta" , clear


global covariates = "age age2 sex bus1 wealth avg_light_quality"

set matsize 800 

global participation_variables = "townhall evaluation"
global gov_provide = "provide1_gov provide2_gov provide3_gov provide4_gov provide5_gov provide6_gov provide7_gov pubgoods1 aid1 aid3"
global capacity_info ="info1 info2 info4 info5"
global capacity_punish ="punish5 punish9"
global capacity_provide = "gov_cap1b gov_cap2b gov_cap3b"
global eval_trust_gov = "gov_perform trust5"
global eval_trust_tax = "dgrkoc_perform trust6"
global transparency = "transparent1 transparent2"

global index_variables = "participation_variables gov_provide capacity_info capacity_punish eval_trust_tax capacity_provide eval_trust_gov transparency "

eststo clear
foreach index in $index_variables{
eststo: xi: avg_effect $`index', x(program $covariates i.stratum) effect(program) control(program==0) cluster(a7) keepmissing
}
esttab using "aes_coefficients.txt", coef("AES") b(3) se(3) compress nogap nonotes star(* 0.10 ** 0.05 *** 0.01) addnote("Standard errors clustered by polygon.") mtitles("Index""Index") nonumbers replace





**********************************************************
**Coefficient plots of individual questions for Appendix**
**********************************************************

** Government responsibility **

use "$data/endline_clean_merged.dta" , clear

global covariates = "age age2 sex bus1 wealth avg_light_quality"
global depvars = "gov_provide provide1_gov provide2_gov provide3_gov provide4_gov provide5_gov provide6_gov provide7_gov pubgoods1 aid3 aid1"
eststo clear
foreach depvar in $depvars{
eststo: reg `depvar' program $covariates i.stratum  , cluster(a7)
est sto `depvar'
}

coefplot gov_provide provide1_gov provide2_gov provide3_gov provide4_gov provide5_gov provide6_gov provide7_gov pubgoods1  aid3 aid1, keep(program program program program program program program program program program program program) legend(off) swapnames aseq offset(0) xaxis(1 2) xla("", axis(1)) ytitle("", axis(2)) yaxis(1 2) yla("",axis(2)) yla("",axis(1)) note("Estimates from OLS regressions in basic specification. SEs clustered by polygon. All variables standardized.", size(vsmall) span) yscale(titlegap(2)) xscale(titlegap(3)) xtitle("OLS coefficient", axis(2)) msize(small) msymbol(circle) mcolor(midblue) mlcolor(dknavy) ciopts(lcolor(dknavy)) xline(0, lcolor(red)) coeflabels(gov_provide="Responsibility of provincial govt (index)" provide1_gov="Provincial govt should provide - schools" provide2_gov="Provincial govt should provide - water" provide3_gov="Provincial govt should provide - health" provide4_gov="Provincial govt should provide - security" provide5_gov="Provincial govt should provide - welfare" provide6_gov="Provincial govt should provide - development" provide7_gov="Provincial govt should provide - roads" pubgoods1="Provincial govt should provide more" aid1="Congo shouldn't need foreign aid" aid3="Provincial govt should replace foreign aid") 

graph export "$root/outputs/coefplot_responsibility.pdf", replace

** Government capacity and integrity **

use "$data/endline_clean_merged.dta" , clear

global covariates = "age age2 sex bus1 wealth avg_light_quality"
global depvars = "capacity_info info1 info2 info4 info5 capacity_punish punish5 punish9 others4 eval_trust_tax dgrkoc_perform trust6 capacity_provide gov_cap1b gov_cap2b gov_cap3b eval_trust_gov trust5 funds_spent funds_deposited gov_perform  transparency transparent1 transparent2"
eststo clear
foreach depvar in $depvars{
eststo: reg `depvar' program $covariates i.stratum  , cluster(a7)
est sto `depvar'
}

coefplot capacity_info info1 info2 info4 info5 capacity_punish punish5 punish9 others4 eval_trust_tax dgrkoc_perform trust6 capacity_provide gov_cap1b gov_cap2b gov_cap3b eval_trust_gov gov_perform  trust5 funds_deposited funds_spent transparency transparent1 transparent2, keep(program program program program program program program program program program program program program program program program) legend(off) swapnames aseq offset(0) xaxis(1 2) xla("", axis(1)) ytitle("", axis(2)) yaxis(1 2) yla("",axis(2)) yla("",axis(1)) note("Estimates from OLS regressions in basic specification. SEs clustered by polygon. All variables standardized. Superscripts denote constituent questions of the" "following indices: 1=Information about taxpayers, 2=Ability to punish evaders, 3=Performance of tax ministry, 4=Ability to provide public goods," "5=Performance of government, 6=Transparency of government", size(vsmall) span) yscale(titlegap(2)) xscale(titlegap(3)) xtitle("OLS coefficient", axis(2)) graphregion(color(white)) plotregion(color(white)) msize(small) msymbol(circle) mcolor(midblue) mlcolor(dknavy) ciopts(lcolor(dknavy)) xline(0, lcolor(red)) coeflabels(info1= "Information about taxpayers (HH location){superscript:1}" info2= "Information about taxpayers (compliance){superscript:1}" info4= "Information about taxpayers (occupation){superscript:1}" info5= "Information about taxpayers (income){superscript:1}"  punish5= "Ability to punish evaders{superscript:2}" punish9= "Ability to punish bribers{superscript:2}" dgrkoc_perform="Approval of tax ministry{superscript:3}" trust6="Trust in tax ministry{superscript:3}"  funds_deposited= "Integrity of tax collectors"  others4 = "Perceived citizen compliance" gov_cap1b= "Ability to pave all city roads{superscript:4}" gov_cap2b= "Ability to electrify all city{superscript:4}" gov_cap3b= "Ability to imprison criminal{superscript:4}" gov_perform="Approval of provincial government{superscript:5}" trust5="Trust in provincial government{superscript:5}" funds_spent= "Integrity of government spending" capacity_info="Information about taxpayers (index)" capacity_punish="Ability to punish evaders (index)" eval_trust_tax="Performance of tax ministry (index)" capacity_provide="Ability to provide public goods (index)" eval_trust_gov="Performance of government (index)" transparency = "Transparency of government (index)" transparent1="Transparency about laws/obligations {superscript:6}" transparent2="Transparency about spending/programs {superscript:6}") 

graph export "$root/outputs/coefplot_capacity.pdf", replace


** Citizen role, interest, and national participation **

global dependent_variables ="citizen_role_politics cit_role1 cit_role2 cit_role3 interest_politics  pol2 pol3 know1 know2 know5 infotest1_gov infotest2_gov infotest3_gov national_participation pol5 march party protest rally"

eststo clear
foreach depvar in $dependent_variables{
eststo: reg `depvar' program $covariates i.stratum  , cluster(a7)
est sto `depvar'
}

coefplot citizen_role_politics cit_role1 cit_role2 cit_role3 interest_politics pol2 pol3 know1 know2 know5 infotest1_gov infotest2_gov infotest3_gov national_participation pol5 march party protest rally, ///
keep(program program program program program program program program program program program program program program program program) ///
legend(off) swapnames aseq offset(0) xaxis(1 2) xla("", axis(1)) ytitle("", axis(2)) yaxis(1 2) yla("",axis(2)) yla("",axis(1)) /// 
note("Estimates from OLS regressions in basic specification. SEs clustered by polygon. All variables standardized. Superscripts denote constituent questions" ///
"of the following indices: 1=Role of citizens in politics, 2=Interest in politics, 3=Engagement with national politics.", size(vsmall) span) ///
yscale(titlegap(2)) xscale(titlegap(3)) xtitle("OLS coefficient", axis(2)) ///
graphregion(color(white)) plotregion(color(white)) msize(small) msymbol(circle) ///
mcolor(midblue) mlcolor(dknavy) ciopts(lcolor(dknavy)) xline(0, lcolor(red)) ///
coeflabels( citizen_role_politics="Role of citizens in politics (index)" cit_role1="Thinks citizens should actively monitor leaders{superscript:1}" cit_role2="Thinks citizens must have voice in politics{superscript:1}" cit_role3 = "Provincial assembly should monitor gov spending{superscript:1}" interest_politics="Interest in politics (index)" pol2="Consumption of political news by radio{superscript:2}" pol3="Consumption of political news by internet{superscript:2}" know1="Knows name of governor{superscript:2}" know2="Knows number of deputies{superscript:2}" know5="Knows names of territories{superscript:2}" infotest1_gov="Chooses to learn about state spending{superscript:2}" infotest2_gov="Chooses to learn number of state employees{superscript:2}" infotest3_gov="Chooses to learn extent of public lighting{superscript:2}" national_participation="Engagement with national politics (index)" pol5="Planning to vote in next election{superscript:3}" party="Participation in a political party{superscript:3}" march="Participation in political marches{superscript:3}" rally="Participation in political rallies{superscript:3}" protest="Participation in political protests{superscript:3}") 
graph export "$root/outputs/coefplot_interest_national.pdf", replace

** Engagement with chiefs and formalization **

global engage_chiefs = "consult_chef salongo know4"
global view_chiefs = "chef_respond trust8"
global formalization = "service1 service2 bus4 title3"

global dependent_variables ="engage_chiefs consult_chef salongo know4 view_chiefs chef_respond trust8 formalization service1 service2 bus4 title3"
eststo clear
foreach depvar in $dependent_variables{
eststo: reg `depvar' program $covariates i.stratum  , cluster(a7)
est sto `depvar'
}

coefplot engage_chiefs consult_chef salongo know4 view_chiefs chef_respond trust8 formalization service1 service2 bus4 title3, ///
keep(program program program program program program program program program program program program program program program program) ///
legend(off) swapnames aseq offset(0) xaxis(1 2) xla("", axis(1)) ytitle("", axis(2)) yaxis(1 2) yla("",axis(2)) yla("",axis(1)) /// 
note("Estimates from OLS regressions in basic specification. SEs clustered by polygon. All variables standardized. Superscripts denote constituent questions" "of the following indices: 1=Engagement with city chiefs, 2=Views of city chiefs, 3=Demand for formalization.", size(vsmall) span) yscale(titlegap(2)) xscale(titlegap(3)) xtitle("OLS coefficient", axis(2)) graphregion(color(white)) plotregion(color(white)) msize(small) msymbol(circle) mcolor(midblue) mlcolor(dknavy) ciopts(lcolor(dknavy)) xline(0, lcolor(red)) coeflabels(engage_chiefs="Engagement with city chiefs (index)" consult_chef="Consulted avenue chief about problem{superscript:1}" salongo="Contributed to local project (salongo){superscript:1}" know4="Knows name of avenue chief{superscript:1}" view_chiefs="Views of city chiefs (index)" chef_respond="Perceived responsiveness of avenue chief{superscript:2}" trust8="Trust of quartier and avenue chiefs{superscript:2}" formalization = "Demand for formalization (index)" service1="Applied for identity document{superscript:3}" service2="Applied for sales license{superscript:3}" bus4="Demand for business permit{superscript:3}" title3="Demand for land title{superscript:3}") 
graph export "$root/outputs/coefplot_chief_formalization.pdf", replace
